// load lead data from 
//	Rees, N., & Fuller, R. (2020). The Toxic Truth: Children's Exposure to 
//		Lead Pollution Undermines a Generation of Future Potential. UNICEF.
//https://www.unicef.org/sites/default/files/2020-07/The-toxic-truth-children's-exposure-to-lead-pollution-2020.pdf

cd "~/Documents/econ/research/current/cognitive/estimation/data"
/*
wbopendata, clear year(2019) long nometadata indicator( ///
 sp.pop.0014.to;	/// Population ages 0-14, total
 sp.pop.1519.fe;	/// Female population 15-19
 sp.pop.1519.ma)	// Male population 15-19
egen pop0_19 = rowtotal(sp_pop*)
keep countrycode pop0_19
save pop0_19, replace
*/


import excel lead.xlsx, first clear
rename AREACOUNTRY country
replace country = "Mexico" if country=="Mexico*"
rename NumberofChildrenwith* Num*
replace NumBLL10 =  subinstr(NumBLL10,"-","0",.)
destring Num*, ignore("*,") replace
keep country Num*
kountry country, from(other) stuck
rename _ISO3N_ iso3n
kountry iso3n, from(iso3n) to(iso3c)
rename _ISO3C_ countrycode
drop iso3n
save lead, replace

merge 1:1 countrycode using pop0_19
drop if _merge==2
drop _merge
gen lead_BLL5 = NumBLL5/pop0_19*100
gen lead_BLL10 = NumBLL10/pop0_19*100
label var lead_BLL5 "% of children 0-19 with BLL > 5 µg/dL"
label var lead_BLL10 "% of children 0-19 with BLL > 10 µg/dL"
keep country* lead_*
keep if lead_BLL5 < .
gen year = 2019
sort countrycode year
compress
save lead, replace


